<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib prefix="sys" uri="/WEB-INF/tld/sys.tld" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>新增/编辑投保申请</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div>
        <div id="pageInTab" class="pageInTab">
                <div tabid="tabA" title="分期申请" lselected="true">
                    <div class="searchArea">
                        <form id="insApplication_form">
                            
                            <div class="fieldset1 tabel_col clearFix">
                                <div class="caption">
                                    <span class="title">被保险人信息</span>
                                </div>
                                <div class="fieldBox col_33">
                                    <div class="label"><span class="requiredSymbol">*</span>被保险人类型</div>
                                    <div class="field">
                                        <input type="radio" name="certTypCd" id="fcertTypCd" onclick="certTypeCd(value)"
                                               value="2">法人 &nbsp;
                                        <input type="radio" name="certTypCd" id="zcertTypCd" onclick="certTypeCd(value)"
                                               value="1" checked="checked"/>自然人
                                    </div>
                                </div>
                                <div class="fieldBox col_33">
                                    <div class="label"><span class="requiredSymbol">*</span>被保险人姓名</div>
                                    <div class="field">
                                        <input type="text" id="insPerNm" name="insPerNm" class="ui-textbox"
                                          value="${application.insPerNm }"     ligerui="width:180" validate="{required:true,maxlength:40,minlength:2}"/>
                                    </div>
                                </div>
                                <div class="fieldBox col_33">
                                     <div class="label"><span class="requiredSymbol">*</span>证件号</div>
                                    <div class="field">
                                        <input type="text" id="idCard" name="idCard" class="ui-textbox"
                                             value="${application.certNo }"   ligerui="width:180" validate="{required:true,minlength:2}"/>
                                    </div>
                                </div>
                              <div class="fieldBox col_33">
                                     <div class="label"><span class="requiredSymbol">*</span>被保险人手机号</div>
                                    <div class="field">
                                        <input type="text" id="mp" name="mp" class="ui-textbox"
                                             value="${application.insPerMobile }"  ligerui="width:180" validate="{required:true,minlength:11}"/>
                                    </div>
                                </div>
                                <div class="fieldBox col_33">
                                    <div id="idCardNo">
                                        <div class="label"><span class="requiredSymbol">*</span>上传身份证正面</div>
                                        <div class="field">
                                            <input type="file" name="idCardPt10" id="idCardPt10"
                                                   onchange="imgPreview(this,'fileCertNo','idCardPt10')"/>
                                            <div style="width:200px; height:100px;">
                                            <c:if test="${empty fileCertNoPath}">
                                                <img id="fileCertNo" style="width:200px; height:100px;display:none"
                                                     src="${fileCertNoPath}">
                                            </c:if>
                                            <c:if test="${not empty fileCertNoPath}">
                                                <img id="fileCertNo" onclick="showimg('fileCertNo','${fileCertNoPath}')"
                                                     style="width:200px; height:100px;" src="${fileCertNoPath}">
                                            </c:if>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="fieldBox col_33">
                                    <div id="idCardNoBack">
                                        <div class="label"><span class="requiredSymbol">*</span>上传身份证反面</div>
                                        <div class="field">
                                            <input type="file" name="idCardPt20" id="idCardPt20"
                                                   onchange="imgPreview(this,'fileBackCertNo')"/>
                                             <div style="width:200px; height:100px;">
                                            <c:if test="${empty fileBackCertNoPath}">
                                                <img id="fileBackCertNo" style="width:200px; height:100px;display:none"
                                                     src="${fileBackCertNoPath}">
                                            </c:if>
                                            <c:if test="${not empty fileBackCertNoPath}">
                                                <img id="fileBackCertNo"
                                                     onclick="showimg('fileBackCertNo','${fileBackCertNoPath}')"
                                                     style="width:200px; height:100px;" src="${fileBackCertNoPath}">
                                            </c:if>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="fieldBox col_33">
                                    <div>
                                        <div id="busLin">
                                            <div class="label"><span class="requiredSymbol">*</span>上传营业执照</div>
                                            <div class="field">
                                                <input type="file" name="busLincePh" id="busLincePh"
                                                       onchange="imgPreview(this,'fileApplyBuss')"/>
                                                <div style="width:200px; height:100px;">
                                                    <c:if test="${empty fileApplyBussPath}">
                                                        <img id="fileApplyBuss"
                                                             style="width:200px; height:100px;display:none"
                                                             src="${fileApplyBussPath}">
                                                    </c:if>
                                                    <c:if test="${not empty fileApplyBussPath}">
                                                        <img id="fileApplyBuss"
                                                             onclick="showimg('fileApplyBuss','${fileApplyBussPath}')"
                                                             style="width:200px; height:100px;"
                                                             src="${fileApplyBussPath}">
                                                    </c:if>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="fieldBox col_33">
                                    <div class="label">上传行驶证正面</div>
                                    <div class="field">
                                        <input type="file" name="vechPro" id="vechPro"
                                               onchange="imgPreview(this,'fileVehicle')"/>
                                        <div style="width:200px; height:100px;">
                                            <c:if test="${empty fileVehiclePath}">
                                                <img id="fileVehicle" style="width:200px; height:100px;display:none"
                                                     src="${fileVehiclePath}">
                                            </c:if>
                                            <c:if test="${not empty fileVehiclePath}">
                                                <img id="fileVehicle"
                                                     onclick="showimg('fileVehicle','${fileVehiclePath}')"
                                                     style="width:200px; height:100px;" src="${fileVehiclePath}">
                                            </c:if>
                                        </div>
                                    </div>
                                </div>
                                <div class="fieldBox col_33">
                                    <div class="label">上传行驶证反面</div>
                                    <div class="field">
                                        <input type="file" name="vechCons" id="vechCons"
                                               onchange="imgPreview(this,'fileVehicleBack')"/>
                                        <div style="width:200px; height:100px;">
                                            <c:if test="${empty fileVehicleBackPath}">
                                                <img id="fileVehicleBack" style="width:200px; height:100px;display:none"
                                                     src="${fileVehicleBackPath}">
                                            </c:if>
                                            <c:if test="${not empty fileVehicleBackPath}">
                                                <img id="fileVehicleBack"
                                                     onclick="showimg('fileVehicleBack','${fileVehicleBackPath}')"
                                                     style="width:200px; height:100px;" src="${fileVehicleBackPath}">
                                            </c:if>
                                        </div>
                                    </div>
                                </div>
                                
                            </div>

                            <!-- <div class="fieldset1 tabel_col clearFix">
                                <div class="caption">
                                    <span class="title">车辆信息</span>
                                </div>
                                <div class="fieldBox col_33">
                                    <div class="label"><span class="requiredSymbol">*</span>车牌号码</div>
                                    <div class="field">
                                        <input type="text" id="carNum" name="carNum" class="ui-textbox"
                                               ligerui="width:180" validate="{required:true,maxlength:10}"/>
                                    </div>
                                </div>
                                <div class="fieldBox col_33">
                                    <div class="label">品牌型号</div>
                                    <div class="field">
                                        <input type="text" id="brandType" name="brandType" class="ui-textbox"
                                               ligerui="width:180" />
                                    </div>
                                </div>
                                <div class="fieldBox col_33">
                                    <div class="label"><span class="requiredSymbol">*</span>发动机号</div>
                                    <div class="field">
                                        <input type="text" id="motorNum" name="motorNum" class="ui-textbox"
                                               ligerui="width:180" validate="{required:true}"/>
                                    </div>
                                </div>
                                <div class="fieldBox col_33">
                                    <div class="label"><span class="requiredSymbol">*</span>VIN码/车架号</div>
                                    <div class="field">
                                        <input type="text" id="vinNum" name="vinNum" class="ui-textbox"
                                               ligerui="width:180" validate="{required:true}"/>
                                    </div>
                                </div>
                                <div class="fieldBox col_33">
                                    <div class="label"></div>
                                    <div class="field">
                                    </div>
                                </div>
                                <div class="fieldBox col_33">
                                    <div class="label"></div>
                                    <div class="field">
                                    </div>
                                </div>
                            </div> -->
					<div class="fieldset1 tabel_col clearFix">
						<div class="caption">
							<span class="title">保险信息</span>
						</div>
						<div class="fieldBox col_33">
							<div class="label"><span class="requiredSymbol">*</span>保险公司</div>
							<div class="field">
                                <input name="insCompCd" id="insCompCd" data-value=" " placeholder="--请选择--" ltype="combobox" validate="{required:true}">
                                <span id="insCompCdSpan" class="requiredSymbol" style="display: none">*</span>
							</div>
						</div>
                        <div class="fieldBox col_33">
							<div class="label"><span class="requiredSymbol">*</span>保险支公司</div>
							<div class="field">
                                <input name="insCompSubCd" id="insCompSubCd" data-value=" " placeholder="--请选择--" ltype="combobox" validate="{required:true}">
                                <span id="insCompSubCdSpan" class="requiredSymbol" style="display: none">*</span>
							</div>
						</div>
						<div class="fieldBox col_33">
							<div class="label"><span class="requiredSymbol">*</span>保险公司所属城市</div>
							<div class="field">
                                <span id="rgnProvNm" name ="rgnProvNm" class="ui-textbox" ></span>
                                <span id="rgnCityNm" name ="rgnCityNm" class="ui-textbox" ></span>
							</div>
						</div>
						

						<div class="fieldBox col_33">
							<div class="label"><span class="requiredSymbol">*</span>商业险起保期限</div>
							<div class="field">
								<input name="plcBgTmBs" id="plcBgTmBs" type="text" class="ui-datepicker" ligerui="width:100"
									   value="<fmt:formatDate value='${policyDetailBs.insBeginDt}' pattern='yyyy-MM-dd'/>" validate="{required:true,date:true,maxlength:40}">
								<input name="plcEndTmBs" id="plcEndTmBs" type="text" disabled="disabled"
                                              class="ui-textbox" ligerui="width:100"
                                               value="<fmt:formatDate value='${policyDetailBs.insEndDt}' pattern='yyyy-MM-dd'/>" validate="{required:true,date:true,maxlength:40}">
							</div>
						</div>
						<div class="fieldBox col_33">
							<div class="label"><span class="requiredSymbol">*</span>商业险保费(元)</div>
							<div class="field">
								<input type="text" id="insPolicyBusAmt" value="${bsAmt }" name ="insPolicyBusAmt" class="ui-textbox" ligerui="width:180" validate="{required:true}"/>
							</div>
						</div>
						<div class="fieldBox col_33">
							<div class="label"></div>
							<div class="field">
							</div>
						</div>
						<div class="fieldBox col_33">
							<div class="label">交强险起保期限</div>
							<div class="field">
								<input name="plcBgTmJq" id="plcBgTmJq" type="text" class="ui-datepicker" ligerui="width:100"
									   value="<fmt:formatDate value='${policyDetailJq.insBeginDt}' pattern='yyyy-MM-dd'/>" >
								<input name="plcEndTmJq" id="plcEndTmJq" type="text" disabled="disabled"
                                              class="ui-textbox" ligerui="width:100"
                                               value="<fmt:formatDate value='${policyDetailJq.insEndDt}' pattern='yyyy-MM-dd'/>" >
							</div>
						</div>
						<div class="fieldBox col_33">
							<div class="label">交强险保费(元)</div>
							<div class="field">
								<input type="text" id="insPolicyJqAmt" value="${jqAmt }" name ="insPolicyJqAmt" class="ui-textbox" ligerui="width:180" />
							</div>
						</div>
						<div class="fieldBox col_33">
							<div class="label"></div>
							<div class="field">
							</div>
						</div>
					<!-- 	<div class="fieldBox col_33">
							<div class="label"><span class="requiredSymbol">*</span>商业险保单号</div>
							<div class="field">
								<input type="text" id="" name ="" class="ui-textbox" ligerui="width:180" validate="{required:true}"/>
							</div>
						</div> -->
						<div class="fieldBox col_33">
							<div class="label"><span class="requiredSymbol">*</span>上传商业投保单</div>
							<div class="field">
                                        <input type="file" name="insPolicyBus" multiple="multiple" id="insPolicyBus"
                                               onchange="imgPreviews(this,'filePolicyB','previewBussDiv','bDiv','insPolicyBus')"/>
                                        <div style="width:200px; height:100px;">
                                            <div id="bDiv">
                                                <c:if test="${empty filePolicyBPathList}">
                                                    <img id="filePolicyB" style="width:200px; height:100px;display:none"
                                                         src="${filePolicyBPathList}">
                                                </c:if>
                                                <c:forEach items="${filePolicyBPathList}" var="buss">
                                                    <c:if test="${empty buss}">
                                                        <img id="filePolicyB"
                                                             style="width:200px; height:100px;display:none"
                                                             src="${buss}">
                                                    </c:if>
                                                    <c:if test="${not empty buss}">
                                                        <img id="filePolicyB"
                                                             onclick="showimg('fileVehicleBack','${buss}')"
                                                             style="width:90px; height:100px;" src="${buss}">
                                                    </c:if>
                                                </c:forEach>
                                            </div>

                                            <div id="previewBussDiv" style="width:200px; height:100px;"></div>
                                        </div>
                                    </div>
						</div>
						<!-- <div class="fieldBox col_33">
							<div class="label"><span class="requiredSymbol">*</span>交强险保单号</div>
							<div class="field">
								<input type="text" id="" name ="" class="ui-textbox" ligerui="width:180" validate="{required:true}"/>
							</div>
						</div> -->
						<div class="fieldBox col_33">
                                    <div class="label">上传交强投保单</div>
                                    <div class="field">
                                        <input type="file" name="insPolicyJQ" id="insPolicyJQ" multiple="multiple"
                                               onchange="imgPreviews(this,'filePolicyJQ','previewJQDiv','jqDiv','insPolicyJQ')"/>
                                        <div style="width:200px; height:100px;">
                                            <div id="jqDiv">
                                                <c:if test="${empty filePolicyJQPathList}">
                                                    <img id="filePolicyJQ"
                                                         style="width:200px; height:100px;display:none"
                                                         src="${filePolicyJQPathList}">
                                                </c:if>
                                                <c:forEach items="${filePolicyJQPathList}" var="jq">
                                                    <c:if test="${empty jq}">
                                                        <img id="filePolicyJQ"
                                                             style="width:200px; height:100px;display:none" src="${jq}">
                                                    </c:if>
                                                    <c:if test="${not empty jq}">
                                                        <img id="filePolicyJQ"
                                                             onclick="showimg('fileVehicleBack','${jq}')"
                                                             style="width:90px; height:100px;" src="${jq}">
                                                    </c:if>
                                                </c:forEach>
                                            </div>
                                            <div id="previewJQDiv" style="width:200px; height:100px;"></div>
                                        </div>
                                    </div>
                                </div>
                             
					</div>
						<!-- hide data -->
						<div class="fieldBox col_100" style="display:none;">
									<div class="field">
										<input name="applicationId" id="applicationId" type="text" class="ui-textbox"
											   value="${applicationId}">
									</div>
									<div class="field">
										<input name="vehLiceId" id="vehLiceId" type="text" class="ui-textbox">
										<input name="delInfoId" id="delInfoId" type="text" class="ui-textbox">
										<input name="insPolicyJqId" id="insPolicyJqId" type="text" class="ui-textbox">
										<input name="insPolicyBusId" id="insPolicyBusId" type="text" class="ui-textbox">
									</div>
									<div class="field">
										<input name="appId" id="appId" type="text" value="${appId}" class="ui-textbox">
									</div>
									<div class="field">
										<input name="fileCertNoPath" id="fileCertNoPath" type="text"
											   value="${fileCertNoPath}" class="ui-textbox">
										<input name="fileBackCertNoPath" id="fileBackCertNoPath" type="text"
											   value="${fileBackCertNoPath}" class="ui-textbox">
										<input name="fileVehiclePath" id="fileVehiclePath" type="text"
											   value="${fileVehiclePath}" class="ui-textbox">
										<input name="fileVehicleBackPath" id="fileVehicleBackPath" type="text"
											   value="${fileVehicleBackPath}" class="ui-textbox">
										<input name="fileApplyBussPath" id="fileApplyBussPath" type="text"
											   value="${fileApplyBussPath}" class="ui-textbox">
										<input name="filePolicyBPathList" id="filePolicyBPathList" type="text"
											   value="${filePolicyBPathList}" class="ui-textbox">
										<input name="filePolicyJQPathList" id="filePolicyJQPathList" type="text"
											   value="${filePolicyJQPathList}" class="ui-textbox">
                                        <input type="text" id="rgnProvCd" name ="rgnProvCd" class="ui-textbox" validate="{required:true}"/>
                                        <input type="text" id="rgnCityCd" name ="rgnCityCd" class="ui-textbox" validate="{required:true}"/>

                                    </div>
									<div class="field">
										<input name="showInsDetail" id="showInsDetail" type="text"
											   value="${showInsDetail}" class="ui-textbox">
										<input name="usrMobile" id="usrMobile" type="text" value="" class="ui-textbox">
									</div>
								</div>
						<input type="hidden" name="prjPrdDtlId" id="prjPrdDtlId" value="${prjPrdDtlId }"/>
						<input type="hidden" name="applyId" id="applyId" value="${applyId }"/>
						<input type="hidden"  name="addOrUpdate" id="addOrUpdate" value="${addOrUpdate }"/>
						
                    </form>
                      <div class="btnsBox" style="text-align: center;">
                                  <span id="saveInsPlcBscInfo_Btn" class="sq-button sq-button-round">保存</span>
                                  <span id="back_Btn"  class="sq-button sq-button-round">返回</span>
                      </div>
                    </div>
                </div>
                 <div tabid="tabB" title="报价方案">
                     <iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
                </div>
            </div>
        </div>
    </div>


    <script type="text/javascript" src="<%=path%>/resource/lib/plugins/ajaxfileupload.js"></script>
    <script>
    var form;
	var pageInApp={}; // to 下一级子窗口 接口
    var pageInTab=null;
    var loadedTabs=[]
    $(function () {
        var orderStatus = "${application.orderStatus}";
        if(StringUtils.isEmpty(orderStatus)|| orderStatus == "1"){
            $("#saveInsPlcBscInfo_Btn").show();
        }else{
            $("#saveInsPlcBscInfo_Btn").hide();
        }
        form = $("#insApplication_form").ligerForm({
            validate: true
        });
        initTab();
        initData();
    });
    
     $("#back_Btn").click(function(event) {
         var callback=GET_W2Wcallback();
         if(callback) callback();
         console.log(GET_W2W());
         Remove_navTab();
     });

    //商业险起保时间change事件
    $("#plcBgTmBs").ligerDateEditor({
        onChangeDate: function (value) {
            var nowDate = new Date();
            var date = new Date(value);
            nowDate.setDate(nowDate.getDate() - 1);

            date.setFullYear(date.getFullYear() + 1);
            date.setDate(date.getDate() - 1);
            liger.get("plcEndTmBs").setValue(date.Format("yyyy-MM-dd"));
        }
    });
    //商业险起保时间change事件
    $("#plcBgTmJq").ligerDateEditor({
        onChangeDate: function (value) {
            var nowDate = new Date();
            var date = new Date(value);
            nowDate.setDate(nowDate.getDate() - 1);
            date.setFullYear(date.getFullYear() + 1);
            date.setDate(date.getDate() - 1);
            liger.get("plcEndTmJq").setValue(date.Format("yyyy-MM-dd"));
        }
    });
    
    function certTypeCd(value) {
        if (value == 1) {
            $("#idCardNo").show();
            $("#idCardNoBack").show();
           // $("#busLin").show();
            document.getElementById('busLin').style.display = "none";
        }
        if (value == 2) {
            document.getElementById('idCardNo').style.display = "none";
            document.getElementById('idCardNoBack').style.display = "none";
            $("#busLin").show();
        }
    }
    
    function imgPreview(fileDom, imgId, fileId) {
        if (!fileDom.files[0]) {
            var img = document.getElementById(imgId);
            document.getElementById(imgId).style.display = "none";
            img.src = "";
        }

        //判断是否支持FileReader
        if (window.FileReader) {
            var reader = new FileReader();
        } else {
            alert("您的设备不支持图片预览功能，如需该功能请升级您的设备！");
        }

        //获取文件
        var files = fileDom.files[0];
        var imageType = /^image\//;
        //是否是图片
        /*  if (!imageType.test(file.type)) {
               top.$.ligerDialog.SQalert({content:"请选择图片", SQ_type: "error"});
              return;
          } */
        //读取完成
        reader.onload = function (e) {
            //获取图片dom
            var img = document.getElementById(imgId);
            //图片路径设置为读取的图片
            img.src = e.target.result;
            img.style.display = "";
        };
        if (files) {
            reader.readAsDataURL(files);
            //reader.readAsDataURL(file);
        }
    }
  //查看图片
    function showimg(tab_id, url) {
        if (url != '') {
            Add_navTab('INS_INFO_IMG' + tab_id, '照片查看', url);
        }
    }
  
    //投保单验证
    function imgPreviews(fileDom, imgId, imgDiv, proDiv, fileId) {
        //判断是否支持FileReader
        if (window.FileReader) {
            var reader = new FileReader();
        } else {
            alert("您的设备不支持图片预览功能，如需该功能请升级您的设备！");
        }
        if (fileDom.files[0]) {
            if (fileDom.files.length > 2) {
                var fileLength = document.getElementById(fileId);
                fileLength.value = '';
                top.$.ligerDialog.SQalert({content: "投保单图片最多两张", SQ_type: "warning"});
                return false;
            }
        }

        if (fileDom.files[0]) {
            var img = document.getElementById(imgId);
            document.getElementById(proDiv).style.display = "none";
        }
        if (!fileDom.files[0]) {
            var img = document.getElementById(imgId);
            img.src = "";
            document.getElementById(proDiv).style.display = "none";
        }

        var dd = document.getElementById(imgDiv);
        dd.innerHTML = "";

        //获取文件
        var fileList = fileDom.files;
        for (var i = 0; i < fileList.length; i++) {
            var imgWidth = 200 / (fileList.length);
            var imgHeight = 100;
            dd.innerHTML += "<div style='float:left' > <img id='img" + imgDiv + i + "' style='width:" + imgWidth + "px; height:" + imgHeight + "px;' /> </div>";
            //获取图片imgi的对象
            var imgObjPreview = document.getElementById("img" + imgDiv + i);
            imgObjPreview.src = window.URL.createObjectURL(fileDom.files[i]);
        }
    }
    
    ////
        var _rgnProvCdUpdataValue = "",//省
        _rgnCityCdUpdataValue = "";//市


    ///////////////////////////////////
    $(function(){
        $("#insCompCd").ligerComboBox({
            valueField: 'key',
            textField: 'value',
            width:200,
            onChangeValue:function(value){
                var insCompSubCd = liger.get("insCompSubCd");
             //   insCompSubCd.selectValue(" ");
                initInsCompBusSelectData();
            }
        });

        $("#insCompSubCd").ligerComboBox({
            valueField: 'key',
            textField: 'value',
            width:200,
        });

        initInsCompSelectData();
    });
    //////////////////////////////////////////////////

    
  // //保险公司 二级联动
  //   $(function () {
  //       $("#insCompNm").ligerComboBox({
  //           valueField: 'key',
  //           textField: 'value',
  //           width: 200,
  //           onChangeValue: function (value) {
  //               if (value) {
  //                   //initInsCompBusSelectData(value);
  //               } else {
  //                   var compBusSelectObj = liger.get("insCompSubNm");
  //                   compBusSelectObj.selectValue(" ");
  //               }
  //           }
  //       });
  //
  //       $("#insCompSubNm").ligerComboBox({
  //           valueField: 'key',
  //           textField: 'value',
  //           width: 200,
  //       });
  //
  //       initInsCompSelectData();
  //   });

  //初始化保险公司
    function initInsCompSelectData() {
        $.ajax({
            type: 'post',
            dataType: 'json',
            async: false,
            url: '<%=path%>/inscare/insapplication/getCompCdRegion.do',
            success: function (msg) {
                if(msg.success == 1){
                    var provSelectObj = liger.get("insCompCd");
                   provSelectObj.setData(msg.data);

                }else{
                    top.$.ligerDialog.SQalert({content:'获取保险公司列表失败', SQ_type: "error"});
                }
            }
        });
    }


    //初始化保险支公司数据(value:省代码)
    function initInsCompBusSelectData() {
        if(!$("#insCompSubCd").length)return;
        var provSelectObj = liger.get("insCompCd");
        var insCompCd = $("#insCompCd").val();
        var _provCd = provSelectObj.findValueByText(insCompCd);
        if(!_provCd){
            top.$.ligerDialog.SQalert({content:"请选择保险公司", SQ_type: "error"});
            return;
        }
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: {insCompId: _provCd},
            url: '<%=path%>/inscare/insapplication/getBusCompByIns.do',
            success: function (msg) {

                if(msg.success == 1){
                    var citySelectObj = liger.get("insCompSubCd");
                    citySelectObj.setData(msg.data);

                }else{
                    top.$.ligerDialog.SQalert({content:'获取支公司列表失败', SQ_type: "error"});
                }
            }
        });
    }
    $(function(){
        $("#insCompSubCd").ligerComboBox({
            valueField: 'key',
            textField: 'value',
            width:200,
            onChangeValue:function(value){
                $("#rgnProvCd").val("");
                $("#rgnProvNm").text("");
                $("#rgnCityCd").val("");
                $("#rgnCityNm").text("");
                initCity(value);
            }
        });
    });
  //验证保险公司与省市是否对应
    function validateBusComp() {
        var compProBus = $("#rgnPrNm").val();
        var compCityBus = $("#rgnCyNm").val();
        var compBus = $("#insCompNm").val();
        if (StringUtils.isEmpty(compBus)) {
            top.$.ligerDialog.SQalert({content: "请选择保险公司", SQ_type: "warning"});
            return;
        }
        if (StringUtils.isEmpty(compProBus) || StringUtils.isEmpty(compCityBus)) {
            top.$.ligerDialog.SQalert({content: "请选择保险公司对应省市", SQ_type: "warning"});
            return;
        }
    }
    $("#backBtn").click(function (event) {
    	Remove_navTab();
    });
  //保存
    $("#saveInsPlcBscInfo_Btn").click(function (event) {
        var prjPrdDtlId = $("#prjPrdDtlId").val();
        var data = form.getData();
        var validata = uploadValidate();
        if (!validata) {
            return false;
        } 
        saveInsPlcBscInfo(data);
       
    });
  
    //保存数据
    function saveInsPlcBscInfo(data) {
    	
	    var insIndent; //身份证正面
	    var insIndentBack; //身份证背面
	    var insVehLice; //行驶证证正面
	    var insVehLiceBack; //行驶证背面
	    var insApplicationBuss; //营业执照
	    var insApplyB; //上传商业投保单
	    var insApplyJQ; //上传交强投保单
	    var wait_dialog;
	    var imageType = /^image\//;
	    var a = $("input[type='radio']:checked").val();
	    var validateRquired = validateRequired();
        if (!validateRquired) {
            return false;
        }
        var _urlinsIndentFiles = '<%=path%>/inscare/upload/uploadIdentity.do';
        var _urlInsVehLiceFiles = '<%=path%>/inscare/upload/uploadInsVehLice.do';
        var _urlApplyBussFiles = '<%=path%>/inscare/upload/uploadInsApplyBuss.do';
        var _urlApplyFiles = '<%=path%>/inscare/upload/uploadInsApply.do';
	    var _url="<%=path%>/inscare/insapplication/addApplication.do";
        var provSelectObj = liger.get("insCompNm");
        var insCompSubNmObj = liger.get("insCompSubNm");
        var rgnProvCdObj = liger.get("rgnPrNm");
        var rgnCityCdObj = liger.get("rgnCyNm");
        var insCompCd = $("#insCompCd").val();//保险公司
        var insCompSubCd =  $("#insCompSubCd").val();//支公司
        var rgnProvCd = $("#rgnProvCd").val();//省份
        var rgnCityCd = $("#rgnCityCd").val();//城市

        var prjPrdDtlId = $("#prjPrdDtlId").val();
        var applyId = $("#applyId").val();
        var addOrUpdate = $("#addOrUpdate").val();
        data["insCompNm"] = insCompCd;
        data["rgnPrNm"] = $("#rgnProvNm").text();;
        data["rgnCyNm"] = $("#rgnCityNm").text();;
        data["insCompSubNm"] = insCompSubCd;
        data["prjPrdDtlId"] = prjPrdDtlId;
        data["applyId"] = applyId;
        data["addOrUpdate"] = addOrUpdate;


         
        ///////////////////////////上传身份证
 		
            if (a == "1") {
                var fileInsIndent = document.getElementById("idCardPt10").files[0]; //身份证正面
                if (StringUtils.isNotEmpty(fileInsIndent)) {
                    if (!imageType.test(fileInsIndent.type)) {
                        top.$.ligerDialog.SQalert({content: "请选择正确的身份证正面照片", SQ_type: "error"});
                        return false;
                    }
                    var fileName = fileInsIndent.name;
                    insIndent = new FormData();
                    insIndent.append("files", fileInsIndent);
                    insIndent.append("name", fileName);
                    insIndent.append("code", '10');
                    insIndent.append("applyId", applyId);
                }
                var fileInsIndentBack = document.getElementById("idCardPt20").files[0];  //身份证反面
                if (StringUtils.isNotEmpty(fileInsIndentBack)) {
                    if (!imageType.test(fileInsIndentBack.type)) {
                        top.$.ligerDialog.SQalert({content: "请选择正确的身份证反面照片", SQ_type: "error"});
                        return false;
                    }
                    var fileName = fileInsIndentBack.name;
                    insIndentBack = new FormData(); // FormData 对象
                    insIndentBack.append("files", fileInsIndentBack); // 文件对象
                    insIndentBack.append("name", fileName);
                    insIndentBack.append("code", '20');
                    insIndentBack.append("applyId", applyId);
                }
            }
        	//行驶证
            var fileInsVehLice = document.getElementById("vechPro").files[0]; //行驶证正面照片
            if (StringUtils.isNotEmpty(fileInsVehLice)) {
                if (!imageType.test(fileInsVehLice.type)) {
                    top.$.ligerDialog.SQalert({content: "请选择正确的行驶证正面照片", SQ_type: "error"});
                    return false;
                }
                var fileName = fileInsVehLice.name;
                insVehLice = new FormData(); // FormData 对象
                insVehLice.append("files", fileInsVehLice); // 文件对象
                insVehLice.append("name", fileName);
                insVehLice.append("code", '10');
                insVehLice.append("applyId", applyId);
            }
            var fileInsVehLiceBack = document.getElementById("vechCons").files[0]; //行驶证反面照片
            if (StringUtils.isNotEmpty(fileInsVehLiceBack)) {
                if (!imageType.test(fileInsVehLiceBack.type)) {
                    top.$.ligerDialog.SQalert({content: "请选择正确的行驶证反面照片", SQ_type: "error"});
                    return false;
                }
                var fileName = fileInsVehLiceBack.name;
                insVehLiceBack = new FormData(); // FormData 对象
                insVehLiceBack.append("files", fileInsVehLiceBack); // 文件对象
                insVehLiceBack.append("name", fileName);
                insVehLiceBack.append("code", '20');
                insVehLiceBack.append("applyId", applyId);
            }
            
            ///
            if (a == "2") {
                var fileApplyBussBack = document.getElementById("busLincePh").files[0]; //营业执照照片
                if (StringUtils.isNotEmpty(fileApplyBussBack)) {
                    if (!imageType.test(fileApplyBussBack.type)) {
                        top.$.ligerDialog.SQalert({content: "请选择正确的营业执照照片", SQ_type: "error"});
                        return false;
                    }
                    var fileName = fileApplyBussBack.name;
                    insApplicationBuss = new FormData(); // FormData 对象
                    insApplicationBuss.append("files", fileApplyBussBack); // 文件对象
                    insApplicationBuss.append("name", fileName);
                    insApplicationBuss.append("code", '10');
                    insApplicationBuss.append("applyId", applyId);
                }
            }
            
            
            var fileinsApplyBF = document.getElementById("insPolicyBus").files[0];
            var fileinsApplyB = document.getElementById("insPolicyBus").files; //商业险投保单照片
            if (StringUtils.isNotEmpty(fileinsApplyBF)) {
                var insApplyBFile = [];
                var fileName = [];
                insApplyB = new FormData(); // FormData 对象

                for (var i = 0; i < fileinsApplyB.length; i++) {
                    insApplyBFile[i] = document.getElementById("insPolicyBus").files[i];
                    if (!imageType.test(fileinsApplyB[i].type)) {
                        top.$.ligerDialog.SQalert({content: "请选择正确的商业险照片", SQ_type: "error"});
                        return false;
                    }
                    fileName = insApplyBFile[i].name;
                    insApplyB.append("files", insApplyBFile[i]); // 文件对象
                    insApplyB.append("name", fileName);
                    insApplyB.append("code", '10');
                    insApplyB.append("applyId", applyId);
                }
            }
            
            var fileinsApplyJQF = document.getElementById("insPolicyJQ").files[0];
            var fileinsApplyJQ = document.getElementById("insPolicyJQ").files; //交强险投保单照片
            if (StringUtils.isNotEmpty(fileinsApplyJQF)) {
                var insApplyJQFile = [];
                var fileName = [];
                insApplyJQ = new FormData(); // FormData 对象

                for (var i = 0; i < fileinsApplyJQ.length; i++) {
                    insApplyJQFile[i] = document.getElementById("insPolicyJQ").files[i];
                    if (!imageType.test(fileinsApplyJQ[i].type)) {
                        top.$.ligerDialog.SQalert({content: "请选择正确的交强险照片", SQ_type: "error"});
                        return false;
                    }
                    fileName = insApplyJQFile[i].name;
                    insApplyJQ.append("files", insApplyJQFile[i]); // 文件对象
                    insApplyJQ.append("name", fileName);
                    insApplyJQ.append("code", '20');
                    insApplyJQ.append("applyId", applyId);
                }
            }
            /////////////
            var insIndentF = false; //判断身份证上传是否执行成功
            var insVehLiceF = false; //判断行驶证上传是否执行成功
            
            if (1 == a) {
                //上传身份证
                if (StringUtils.isEmpty(fileCertNoPath) || (StringUtils.isNotEmpty(fileCertNoPath) && StringUtils.isNotEmpty(fileInsIndent))) {
                    insIndentF = saveInsIndent(_urlinsIndentFiles, insIndent, insIndentF);
                    if (!insIndentF) {
                        return false;
                    }
                }
                //上传身份证反面
                if (StringUtils.isEmpty(fileBackCertNoPath) || (StringUtils.isNotEmpty(fileBackCertNoPath) && StringUtils.isNotEmpty(fileInsIndentBack))) {
                    insIndentF = saveInsIndent(_urlinsIndentFiles, insIndentBack, insIndentF);
                    if (!insIndentF) {
                        return false;
                    }
                }
            }
         
        
            //上传行驶证
            if (StringUtils.isEmpty(fileVehiclePath) || (StringUtils.isNotEmpty(fileVehiclePath) && StringUtils.isNotEmpty(insVehLice))) {
                insVehLiceF = saveInsVehLice(_urlInsVehLiceFiles, insVehLice, insVehLiceF);
                if (!insVehLiceF) {
                    return false;
                }
            } else {
                insVehLiceF = true;
            }
            //上传行驶证反面
            if (StringUtils.isEmpty(fileVehicleBackPath) || (StringUtils.isNotEmpty(fileVehicleBackPath) && StringUtils.isNotEmpty(fileInsVehLiceBack))) {
                if (insVehLiceF) {
                    insVehLiceF = saveInsVehLice(_urlInsVehLiceFiles, insVehLiceBack, insVehLiceF);
                }
            }
            
            ////////
            var bussBool = false;
            if (insVehLiceF) {
                //保存营业执照
                if ((StringUtils.isEmpty(fileApplyBussPath) || StringUtils.isNotEmpty(fileApplyBussPath)) && StringUtils.isNotEmpty(fileApplyBussBack)) {
                    bussBool = saveInsApplicationBuss(_urlApplyBussFiles, insApplicationBuss, bussBool);
                } else {
                    bussBool = true;
                }
                if (a == 2 && bussBool) {
                    saveModify(_url, data);
                }
                //上传商险投保单
                if (fileinsApplyB.length > 0) {
                    var boolBf = false;
                    boolBf = saveInsApply(_urlApplyFiles, insApplyB);
                    if (!boolBf) {
                        return false;
                    }
                }
                //上传交强险
                if (fileinsApplyJQ.length > 0) {
                    var boolJQf = false;
                    boolJQf = saveInsApply(_urlApplyFiles, insApplyJQ);
                    if (!boolJQf) {
                        return false;
                    }
                }
            } 
              //保存数据
              if (a == 1 && insVehLiceF) {
                  saveModify(_url, data);
              }
	}

    //上传保险单
    function saveInsApply(_url, data) {
        var resultData = false;
        $.ajax({
            url: _url,
            type: 'post',
            data: data,
            processData: false,
            contentType: false,
            async: false,
            dataType: "json",
            success: function (msg) {   //提交成功后自动执行的处理函数，参数data就是服务器返回的数据。
                if (msg.success == 1) {
                    resultData = true;
                } else {
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    resultData = false;
                }
            },
            error: function (data, status, e) {
                resultData = false//提交失败自动执行的处理函数。
                console.error(e);
            }
        });

        return resultData;
    }

    //上传营业执照
    function saveInsApplicationBuss(_url, data, bussBool) {
        $.ajax({
            url: _url,
            type: 'post',
            data: data,
            processData: false,
            contentType: false,
            async: false,
            dataType: "json",
            success: function (msg) {   //提交成功后自动执行的处理函数，参数data就是服务器返回的数据。
                if (msg.success == 1) {
                    bussBool = true;
                } else {
                    bussBool = true;
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            },
            error: function (data, status, e) {  //提交失败自动执行的处理函数。
                console.error(e);
            }
        });
        return bussBool;
    }

    //上传行驶证信息
    function saveInsVehLice(_url, data, insVehLiceF) {
        $.ajax({
            url: _url,
            type: 'post',
            data: data,
            processData: false,
            contentType: false,
            async: false,
            dataType: "json",
            success: function (msg) {   //提交成功后自动执行的处理函数，参数data就是服务器返回的数据。
                if (msg.success == 1) {
                    insVehLiceF = true;
                } else {
                    insVehLiceF = false;
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            },
            error: function (data, status, e) {  //提交失败自动执行的处理函数。
                console.error(e);
            }
        });
        return insVehLiceF;
    }
    //上传身份证信息
    function saveInsIndent(_url, data, insIndentF) {
        $.ajax({
            url: _url,
            type: 'post',
            data: data,
            processData: false,
            contentType: false,
            async: false,
            dataType: "json",
            success: function (msg) {   //提交成功后自动执行的处理函数，参数data就是服务器返回的数据。
                if (msg.success == 1) {
                    insIndentF = true;
                } else {
                    insIndentF = false;
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            },
            error: function (data, status, e) {  //提交失败自动执行的处理函数。
                console.error(e);
            }
        });
        return insIndentF;
    }
    //保存 编辑
    function saveModify(_url, data) {
      //  var mobile = $("#custMagerMp").val();
     
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: data,
            url: _url,
            beforeSend: function () {
                wait_dialog = top.$.ligerDialog.SQalert({
                    content: LogUtils.LOG_CMM_DATA_LOADING,
                    SQ_type: "waitting"
                });
            },
            success: function (msg) {   //提交成功后自动执行的处理函数，参数data就是服务器返回的数据。
                wait_dialog.close();
                if (msg.success == 1) {
                    tabBool = true;
                    var usrMobile = $("#usrMobile").val();
                    if (StringUtils.isNotEmpty(usrMobile)) {
                        top.$.ligerDialog.SQalert({
                            content: "该客户已绑定过手机号:" + usrMobile + ",现更改为:" + usrMobile + "&nbsp;&nbsp;修改成功",
                            SQ_type: "success"
                        });
                    } else {
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        var callback=GET_W2Wcallback();
                        if(callback) callback();
                        console.log(GET_W2W());
                        Remove_navTab();                       	
                    }
                } else {
                    wait_dialog.close();
                    top.$.ligerDialog.SQalert({
                        content: msg.info,
                        SQ_showButtons: true,
                        SQ_type: "error",
                        SQ_onBtnclick: function (item, Dialog) {
                            var callback=GET_W2Wcallback();
                            if(callback) callback();
                            console.log(GET_W2W());
                            Remove_navTab();
                        },

                    });
                }
            }, error: function (data, status, e) {  //提交失败自动执行的处理函数。
                wait_dialog.close();
                top.$.ligerDialog.SQalert({
                    content: msg.info,
                    SQ_showButtons: true,
                    SQ_type: "error",
                    SQ_onBtnclick: function (item, Dialog) {
                        var callback=GET_W2Wcallback();
                        if(callback) callback();
                        console.log(GET_W2W());
                        Remove_navTab();
                    },

                });
            }
        });
    }
    function initData(){
    	var compNm = "${application.insCompId}";
    	var insPerType = "${application.insPerType}";
    	var compSubNm = "${application.insCompSubId}";
    	var prNm = "${application.rgnPrNm}";
    	var CyNm = "${application.rgnCyNm}";



    	form.setData({
            insCompSubCd:compSubNm,
            insCompCd:compNm,

        });
    	if(StringUtils.isEmpty(insPerType)){
    		insPerType = 1;
    	}
    	
        $("input[type=radio][name='certTypCd'][value='" + insPerType + "']").prev(".l-radio").click();

    }
    
    //验证必填数据
    function validateRequired() {
        var insPerNm = $("#insPerNm").val();//被保险人姓名
        var idCard = $("#idCard").val();//证件号
        var mp = $("#mp").val();//被保人手机号
        var insCompNm = $("#insCompCd").val();//保险公司
        var insCompSubCd =  $("#insCompSubCd").val();//支公司
        var rgnPrNm = $("#rgnProvCd").val();//省份
        var rgnCyNm = $("#rgnCityCd").val();//城市
      // var insCompSubNm = $("#insCompSubNm").val();//支公司
        var plcBgTmBs = $("#plcBgTmBs").val();//商业险起保时间
        var insPolicyBusAmt = $("#insPolicyBusAmt").val();//商业险保费
        var insPolicyJqAmt = $("#insPolicyJqAmt").val();//交强险保费
        var plcBgTmJq = $("#plcBgTmJq").val();
        var insPolicyJQ =$("#insPolicyJQ").val();
        
        if (StringUtils.isEmpty(insPerNm)) {
            top.$.ligerDialog.SQalert({content: "被保险人姓名不能为空", SQ_type: "error"});
            return false;
        }
        if (StringUtils.isEmpty(idCard)) {
            top.$.ligerDialog.SQalert({content: "证件号不能为空", SQ_type: "error"});
            return false;
        }
        if (StringUtils.isEmpty(mp)) {
            top.$.ligerDialog.SQalert({content: "被保人手机号不能为空", SQ_type: "error"});
            return false;
        }
        if (StringUtils.isEmpty(insCompNm)) {
            top.$.ligerDialog.SQalert({content: "保险公司不能为空", SQ_type: "error"});
            return false;
        }
        if (StringUtils.isEmpty(rgnPrNm)) {
            top.$.ligerDialog.SQalert({content: "省份不能为空", SQ_type: "error"});
            return false;
        }
        if (StringUtils.isEmpty(rgnCyNm)) {
            top.$.ligerDialog.SQalert({content: "城市不能为空", SQ_type: "error"});
            return false;
        }
        if (StringUtils.isEmpty(insCompSubCd)) {
            top.$.ligerDialog.SQalert({content: "保险支公司不能为空", SQ_type: "error"});
            return false;
        }

        if (StringUtils.isEmpty(plcBgTmBs)) {
            top.$.ligerDialog.SQalert({content: "商业险起保时间不能为空", SQ_type: "error"});
            return false;
        }
        if (StringUtils.isEmpty(insPolicyBusAmt)) {
            top.$.ligerDialog.SQalert({content: "商业险保费不能为空", SQ_type: "error"});
            return false;
        }
        if (!NumberUtils.isUnsignedNumeric(insPolicyBusAmt)) {
            top.$.ligerDialog.SQalert({content: "商业险保费不能为负数和字母", SQ_type: "error"});
            return false;
        }
        if (parseFloat(insPolicyBusAmt)<=0) {
            top.$.ligerDialog.SQalert({content: "商业险保费不能小于等于0", SQ_type: "error"});
            return false;
        }
        if (StringUtils.isNotEmpty(insPolicyJqAmt)) {
        	if(parseFloat(insPolicyJqAmt)>0){
	        	if(StringUtils.isEmpty(plcBgTmJq)){
	        		top.$.ligerDialog.SQalert({content: "交强险起保时间不能为空", SQ_type: "error"});
	        		return false;
	        	}
        	}
        	if (!NumberUtils.isUnsignedNumeric(insPolicyJqAmt)) {
                 top.$.ligerDialog.SQalert({content: "交强险保费不能为负数和字母", SQ_type: "error"});
                 return false;
             }
        
        }
        
        if (NumberUtils.isUnsignedNumeric(insPolicyJqAmt)) {
            
            if(parseFloat(insPolicyJqAmt)<0){
            	 top.$.ligerDialog.SQalert({content: "交强险保额不能小于0", SQ_type: "error"});
                 return false;
            }
        }
        return true;
    }
    //上传验证
    function uploadValidate() {
    //	var fileInsIndent = document.getElementById("idCardPt10").files[0]; //身份证正面
    	var idCard10 = $("#idCardPt10").val();//身份证正面
    	var idCard20 = $("#idCardPt20").val();
    	var busLincePh = $("#busLincePh").val();//营业执照
    	var vechPro = $("#vechPro").val();//行驶证正面
    	var vechCons = $("#vechCons").val();//行驶证反面
    	var insPolicyBus = $("#insPolicyBus").val();//商业险保单
    	
        var fileCertNoPath = $("#fileCertNoPath").val();
        var fileBackCertNoPath = $("#fileBackCertNoPath").val();
        var fileVehiclePath = $("#fileVehiclePath").val();
        var fileVehicleBackPath = $("#fileVehicleBackPath").val();
        var fileApplyBussPath = $("#fileApplyBussPath").val();
        var filePolicyBPathList = $("#filePolicyBPathList").val();
        var filePolicyJQPathList = $("#filePolicyJQPathList").val();
        var certType = $("input[type='radio']:checked").val();
        var insPolicyJqAmt = $("#insPolicyJqAmt").val();//交强险保费
        var insPolicyJQ =$("#insPolicyJQ").val();
        var addOrUpdate = $("#addOrUpdate").val();
        if(addOrUpdate =="add"){
	  		if(certType=="1"){
	  			 if (StringUtils.isEmpty(idCard10)) {
	  	            top.$.ligerDialog.SQalert({content: "身份证正面不能为空", SQ_type: "error"});
	  	            return false;
	  	        }
	  			if (StringUtils.isEmpty(idCard20)) {
	  	            top.$.ligerDialog.SQalert({content: "身份证反面不能为空", SQ_type: "error"});
	  	            return false;
	  	        }
	  		}
	  		if(certType=="2"){
	  			 if (StringUtils.isEmpty(busLincePh)) {
	  	            top.$.ligerDialog.SQalert({content: "营业执照不能为空", SQ_type: "error"});
	  	            return false;
	  	        }
	  		}
  		 	
  		 	if (StringUtils.isEmpty(insPolicyBus)) {
  	            top.$.ligerDialog.SQalert({content: "商业险投保单不能为空", SQ_type: "error"});
  	            return false;
  	        }
  		 	if (StringUtils.isNotEmpty(insPolicyJqAmt) && NumberUtils.isUnsignedNumeric(insPolicyJqAmt) && parseFloat(insPolicyJqAmt)> 0) {
  		 		
  		 		if (StringUtils.isEmpty(insPolicyJQ)) {
  	  	            top.$.ligerDialog.SQalert({content: "交强险投保单不能为空", SQ_type: "error"});
  	  	            return false;
  	  	        }
  	        }
        }
        if(addOrUpdate =="update"){
        	
	  		if(certType=="1"){
	  			
	  			if (StringUtils.isEmpty(fileCertNoPath) && StringUtils.isEmpty(idCard10)) {
	  				top.$.ligerDialog.SQalert({content: "身份证正面不能为空", SQ_type: "error"});
	  	            return false;
	  	        }
	  			if (StringUtils.isEmpty(fileBackCertNoPath) && StringUtils.isEmpty(idCard20)) {
	  				top.$.ligerDialog.SQalert({content: "身份证反面不能为空", SQ_type: "error"});
	  	            return false;
	  	        }
	  		}
	  		if(certType=="2"){
	  			 if (StringUtils.isEmpty(fileApplyBussPath) && StringUtils.isEmpty(busLincePh)) {
	  	            top.$.ligerDialog.SQalert({content: "营业执照不能为空", SQ_type: "error"});
	  	            return false;
	  	        }
	  		}
	  		
  		 	if (StringUtils.isEmpty(filePolicyBPathList) && StringUtils.isEmpty(insPolicyBus)) {
  	            top.$.ligerDialog.SQalert({content: "商业险投保单不能为空", SQ_type: "error"});
  	            return false;
  	        }
  		 	
  		 	if (StringUtils.isNotEmpty(insPolicyJqAmt) && NumberUtils.isUnsignedNumeric(insPolicyJqAmt) && parseFloat(insPolicyJqAmt)>0) {
  		 		if (StringUtils.isEmpty(filePolicyJQPathList)  && StringUtils.isEmpty(insPolicyJQ)) {
  	  	            top.$.ligerDialog.SQalert({content: "交强险投保单不能为空", SQ_type: "error"});
  	  	            return false;
  	  	        }
  	        }
        }
  		
  		
        return true;
    }

	//初始化Tab页
    function initTab(){
    	 var applyId = $("#applyId").val();
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            minIframeHeight: GET_minIframeHeight(),
            onAfterSelectTabItem: function(tabid) {
            	currTab = tabid;//赋值是哪个Tab页面
                if (loadedTabs.indexOf(tabid)<0) {
                    loadedTabs.push(tabid);
                    switch (tabid){
                        case "tabB":
                            pageInTab.setTabItemSrc(tabid, "<%=path%>/inscare/insapplication/toPricingPage.do?applicationId="+applyId);
                            break;
                       
                    }
                };
                SetIframe_height();
            }
        });

        $.extend(true, pageInApp, {
            pageInTab: pageInTab
        });
    }
    
    function initCity(value){
        if(!$("#insCompSubCd").length)return;
        var insCompSubCdObj = liger.get("insCompSubCd");
        var insCompSubCd = $("#insCompSubCd").val();
        var subCd = insCompSubCdObj.findValueByText(insCompSubCd);
        $.ajax({
            type: 'post',
            dataType:'json',
            data:{compId:subCd},
            url: '<%=path%>/inscare/insapplication/getCityCd.do',
            success:function(msg){
                if(msg.success == 1){
                    $("#rgnProvCd").val(msg.data.rgnPrCd);
                    $("#rgnProvNm").text(msg.data.rgnPrNm);
                    $("#rgnCityCd").val(msg.data.rgnCyCd);
                    $("#rgnCityNm").text(msg.data.rgnCyNm);
                }
            }
        });
    }
    </script>
</body>
</html>
